<?php

/**
 * This is the model class for table "agenda_kegiatan".
 *
 * The followings are the available columns in table 'agenda_kegiatan':
 * @property string $id_agenda_kegiatan
 * @property string $waktu_mulai
 * @property string $waktu_selesai
 * @property string $lokasi
 * @property string $catatan
 * @property string $id_kegiatan
 * @property string $id_pegawai
 *
 * The followings are the available model relations:
 * @property MstJenisKegiatan $idKegiatan
 * @property MstPegawai $idPegawai
 */
class AgendaKegiatan extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AgendaKegiatan the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'agenda_kegiatan';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('waktu_mulai, waktu_selesai, id_kegiatan, id_pegawai', 'required'),
			array('lokasi', 'length', 'max'=>200),
			array('id_kegiatan, id_pegawai', 'length', 'max'=>20),
			array('catatan', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_agenda_kegiatan, waktu_mulai, waktu_selesai, lokasi, catatan, id_kegiatan, id_pegawai', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'Kegiatan' => array(self::BELONGS_TO, 'MstJenisKegiatan', 'id_kegiatan'),
			'Pegawai' => array(self::BELONGS_TO, 'MstPegawai', 'id_pegawai'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_agenda_kegiatan' => 'Id Agenda Kegiatan',
			'waktu_mulai' => 'Waktu Mulai',
			'waktu_selesai' => 'Waktu Selesai',
			'lokasi' => 'Lokasi',
			'catatan' => 'Catatan',
			'id_kegiatan' => 'Id Kegiatan',
			'id_pegawai' => 'Id Pegawai',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_agenda_kegiatan',$this->id_agenda_kegiatan,true);
		$criteria->compare('waktu_mulai',$this->waktu_mulai,true);
		$criteria->compare('waktu_selesai',$this->waktu_selesai,true);
		$criteria->compare('lokasi',$this->lokasi,true);
		$criteria->compare('catatan',$this->catatan,true);
		$criteria->compare('id_kegiatan',$this->id_kegiatan,true);
		$criteria->compare('id_pegawai',$this->id_pegawai,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}